package com.cherrish.demo.bio;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.Charset;
import java.util.Scanner;

/**
 * @author ccl
 * @time 2019-02-25 10:38
 * @name BiooClient
 * @desc:
 */
public class BiooClient {
    public static void main(String[] args) {
        BioClient1 client1 = new BioClient1("localhost", 9010);
        client1.run();
    }

   static class BioClient1{
        private String host;
        private int port;

        public BioClient1(String host, int port) {
            this.host = host;
            this.port = port;
        }

        public void run() {
            try(Socket socket = new Socket(host, port); OutputStream out = socket.getOutputStream();){
                Scanner scanner = new Scanner(System.in);
                System.out.println("Please Input: ");
                String msg = scanner.nextLine();
                out.write(msg.getBytes(Charset.forName("UTF-8")));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
